
function runNian(y){
    if(y % 400 === 0||(y % 4 === 0 && y % 100 !== 0)){
        return true;
    }else{
        return false;
    }
}

var year=2019;
var mounth=5;

document.querySelector("#nian").innerHTML=(year);
document.querySelector("#yue").innerHTML=(mounth);


//从2000到去年总天数
var days=0;
for (var i=1980;i<year;i++){
    if(runNian(i)){
        days += 366;
    }else {
        days += 365;
    }
}

//加上4月月底总天数
for(var l=1;l<mounth;l++){
    switch (l){
        case 1:
            days += 31;
            break;
        case 2:
            if (runNian(year)){
                days += 29;
            }else {
                days += 28;
            }
            break;
        case 3:
            days += 31;
            break;
        case 4:
            days += 30;
            break;
        case 5:
            days += 31;
            break;
        case 6:
            days += 30;
            break;
        case 7:
            days += 31;
            break;
        case 8:
            days += 31;
            break;
        case 9:
            days += 30;
            break;
        case 10:
            days += 31;
            break;
        case 11:
            days += 30;
            break;
        case 12:
            days += 31;
            break;
    }
}
console.log(days);

//本月天数
var day=0;
switch (5){
    case 1:
        day += 31;
        break;
    case 2:
        if (runNian(year)){
            day += 29;
        }else {
            day += 28;
        }
        break;
    case 3:
        day += 31;
        break;
    case 4:
        day += 30;
        break;
    case 5:
        day += 31;
        break;
    case 6:
        day += 30;
        break;
    case 7:
        day += 31;
        break;
    case 8:
        day += 31;
        break;
    case 9:
        day += 30;
        break;
    case 10:
        day += 31;
        break;
    case 11:
        day += 30;
        break;
    case 12:
        day += 31;
        break;
}

console.log(day);
//上个月天数
var da=0;
switch (4){
    case 1:
        da += 31;
        break;
    case 2:
        if (runNian(year)){
            da += 29;
        }else {
            da += 28;
        }
        break;
    case 3:
        da += 31;
        break;
    case 4:
        da += 30;
        break;
    case 5:
        da += 31;
        break;
    case 6:
        da += 30;
        break;
    case 7:
        da += 31;
        break;
    case 8:
        da += 31;
        break;
    case 9:
        da += 30;
        break;
    case 10:
        da += 31;
        break;
    case 11:
        da += 30;
        break;
    case 12:
        da += 31;
        break;
}
console.log(da);

//因为2000年1月一号是从星期六开始的，我想让它从星期日开始，所以加6；
days +=2;

var n= days % 7;
console.log(n);


var e= 42;

var m=e - n - day;
console.log(m);


//获取当前时间
var thsj = new Date().getDate();

var la = document.querySelector("#date");

for (var j=da-n+1;j<=da;j++) {
    la.innerHTML+="<span class='h'>"+j+"</span>"
}


for (var a=1;a<=day;a++){
    if (a===thsj){
        la.innerHTML+="<span class='today'>"+a+"</span>"
    }else{
        la.innerHTML+="<span>"+a+"</span>";
    }
}



for (var r=1;r<=m;r++){
    la.innerHTML+="<span class='h'>"+r+"</span>";
}